from flask_appbuilder import Model
from sqlalchemy import Column, Integer, String, Text

from myapp.models.helpers import AuditMixinNullable

metadata = Model.metadata


class DockerCommits(Model, AuditMixinNullable):
    __tablename__ = 'docker_commits'
    id = Column(Integer, primary_key=True)

    # Defines a column to store the status of the commit operation (e.g., 'pending', 'success', 'failed').
    status = Column(String(100), nullable=True, comment='状态')
    # Defines a column to indicate the source or trigger of this commit operation (e.g., 'notebook', 'service').
    source = Column(String(100), nullable=True, comment='来源')
    # Defines a column to store the ID of the container that is being committed into a new image.
    container_id = Column(String(200), nullable=True, comment='容器id')
    # Defines a column to store the IP address of the host machine where the container is running.
    container_host_ip = Column(String(100), nullable=True, comment='容器host_ip')
    # Defines a column to store any error messages if the commit operation fails.
    err_msg = Column(Text(65536), nullable=True, default='', comment='错误信息')
    # Defines a column for the name of the new Docker image being created.
    image_name = Column(String(200), nullable=True, comment='镜像名称')
    # Defines a column for the version or tag of the new Docker image.
    image_version = Column(String(200), nullable=True, comment='镜像版本')
    # Defines a column for a user-provided description of the new image.
    image_desc = Column(Text(65536), nullable=True, default='', comment='镜像描述')
    # Defines a column to store the ID of the image repository where the new image will be pushed.
    repo_id = Column(Integer, nullable=True, comment='镜像仓库id')
    # Defines a column to store the ID of the source entity that initiated the commit (e.g., the notebook ID).
    source_id = Column(Integer, nullable=True, comment='来源ID')

    def __repr__(self):
        return self.id
